import { basePrefix } from "@/config";
import { config } from "@/option/config";
import request from "../axios";
export const getList = (params) =>
    request({
        url: basePrefix + "/visual/list",
        method: "get",
        params: params
    });

export const copyObj = (id) =>
    request({
        url: basePrefix + "/visual/copy",
        method: "post",
        params: {
            id: id
        }
    });

export const getCategory = (params) =>
    request({
        url: basePrefix + "/category/list",
        method: "get",
        params: params
    });

export const getObj = (id, siteId, tenantId, userId) =>
    request({
        url: basePrefix + "/visual/detail",
        method: "get",
        params: {
            id
            // siteId,
            // tenantId,
            // userId,
            // sign: ""
        }
    });
export const uploadImg = (file) =>
    request({
        url: basePrefix + "/visual/put-file",
        method: "post",
        data: "file=" + file,
        headers: { "Content-Type": "multipart/form-data" }
    });

export const addObj = (data) =>
    request({
        url: basePrefix + "/visual/save",
        method: "post",
        data: {
            visual: {
                password: data.password,
                category: data.category,
                status: data.status,
                title: data.title
            },
            config: {
                detail: JSON.stringify(
                    Object.assign(config, {
                        name: data.title,
                        width: data.width,
                        height: data.height
                    })
                ),
                component: "[]"
            }
        }
    });

export const updateComponent = (data) =>
    request({
        url: basePrefix + "/visual/update",
        method: "post",
        data: data
    });

export const updateObj = (data) =>
    request({
        url: basePrefix + "/visual/update",
        method: "post",
        data: {
            visual: {
                id: data.id,
                password: data.password,
                category: data.category,
                status: data.status,
                title: data.title
            }
        }
    });

export const delObj = (id) =>
    request({
        url: basePrefix + "/visual/remove",
        method: "post",
        params: {
            ids: id
        }
    });
